Skip to content

Conversation

@Manuelvaas
Copy link

@Manuelvaas Manuelvaas commented Jan 21, 2026

Description

relates to STACKITCLI-307 and #1214

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see e.g. here)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

Fixed tests and linter
relates to STACKITCLI-307 and #1214
relates to STACKITCLI-307 and #1214
tests added
network ids included in list of project NICs
@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/network-interface/list 56.79% (+5.85%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/network-interface/list/list.go 56.79% (+5.85%) 81 (+28) 46 (+19) 35 (+9) 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/stackitcloud/stackit-cli/internal/cmd/network-interface/list/list_test.go

if err != nil {
return fmt.Errorf("list network interfaces: %w", err)
}
if model.NetworkId == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since model.NetworkId is optional now, it should be defined as type *string instead of string in the inputModel struct type. nil will mean the flag wasn't set, non-nil will mean the flag was set by the user.

}

// Truncate output
items := *resp.Items
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential nil pointer dereference, take care of it please

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Args: args.NoArgs,
Example: examples.Build(
examples.NewExample(
`Lists all network interfaces in your current project`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`Lists all network interfaces in your current project`,
`Lists all network interfaces`,

That's the default to list the stuff of your current project, you can leave that out

}

sort.SliceStable(nics, func(i, j int) bool {
result := bytes.Compare([]byte(*nics[i].NetworkId), []byte(*nics[j].NetworkId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why all the overkill with byte conversions?

slices.SortFunc(nics, func(a, b iaas.NIC) int {
		return cmp.Compare(*a.NetworkId, *b.NetworkId)
})

Long: "Lists all network interfaces of a network.",
Args: args.NoArgs,
Example: examples.Build(
examples.NewExample(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe leave some general note at the top of this file that this subcommand implementation is cursed because it uses two different API endpoints in the background. So it's documented properly for the future.

Please also note it down in the list for our next sync with IaaS that we report this weird API design so they consider changing it on the next API version bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants